﻿using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using VitCode.Castle.Entities;
using VitCode.ObjectResolutionHelper;

namespace Demo.Core.Entities
{
    /// <summary>
    /// 资产类型
    /// </summary>
    [OrMemo("资产类型")]
    public class AssetType : BaseEntity
    {
        protected string m_Class;

        protected string m_ClassCode;

        protected string m_Item;

        protected string m_ItemCode;

        protected string m_List;

        protected string m_ListCode;
        protected string m_Name;

        protected string m_Node;

        protected string m_NodeCode;
        protected string m_TypeCode;

        public override StringCollection GetKeyProNames()
        {
            return new StringCollection{"TypeCode","Name"};
        }

        
        /// <summary>
        /// 类编码
        /// </summary>
        [OrMemo("类编码")]
        public virtual string ClassCode
        {
            get { return m_ClassCode; }
            set { m_ClassCode = value; }
        }

        /// <summary>
        /// 项名称
        /// </summary>
        [OrMemo("项名称")]
        public virtual string Item
        {
            get { return m_Item; }
            set { m_Item = value; }
        }

        /// <summary>
        /// 项编码
        /// </summary>
        [OrMemo("项编码")]
        public virtual string ItemCode
        {
            get { return m_ItemCode; }
            set { m_ItemCode = value; }
        }

        /// <summary>
        /// 类名称
        /// </summary>
        [OrMemo("类名称")]
        public virtual string Class
        {
            get { return m_Class; }
            set { m_Class = value; }
        }


        /// <summary>
        /// 目名称
        /// </summary>
        [OrMemo("目名称")]
        public virtual string List
        {
            get { return m_List; }
            set { m_List = value; }
        }

        /// <summary>
        /// 目编码
        /// </summary>
        [OrMemo("目编码")]
        public virtual string ListCode
        {
            get { return m_ListCode; }
            set { m_ListCode = value; }
        }

        /// <summary>
        /// 节名称
        /// </summary>
        [OrMemo("节名称")]
        public virtual string Node
        {
            get { return m_Node; }
            set { m_Node = value; }
        }

        /// <summary>
        /// 节编码
        /// </summary>
        [OrMemo("节编码")]
        public virtual string NodeCode
        {
            get { return m_NodeCode; }
            set { m_NodeCode = value; }
        }


        /// <summary>
        /// 名称
        /// </summary>
        [OrMemo("名称")]
        public virtual string Name
        {
            get { return m_Name; }
            set { m_Name = value; }
        }

        /// <summary>
        /// 类别编码(类编码-项编码-目编码-节编码)
        /// </summary>
        [OrMemo("类别编码")]
        public virtual string TypeCode
        {
            get { return m_TypeCode; }
            set { m_TypeCode = value; }
        }

        /// <summary>
        /// 重写Equals方法
        /// </summary>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(obj, this))
                return true;
            if (obj == null)
                return false;
            var sObj = obj as AssetType;
            return sObj != null && (sObj.Id == m_Id || ((sObj.TypeCode == m_TypeCode)));
        }


        public override StringCollection GetUniqueComposeProNames()
        {
            return new StringCollection{"TypeCode","Name"};
        }

        /// <summary>
        /// 重写GetHashCode方法
        /// </summary>
        public override int GetHashCode()
        {
            int hash = 166;
            hash = 16*hash*m_Id.GetHashCode();
            return hash;
        }

        /// <summary>
        /// 重写ToString方法
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return m_TypeCode + "_" +m_Name;
        }

        public override void SetSysExPro()
        {
            base.SetSysExPro();
            m_TypeCode = m_ClassCode + "-" + m_ItemCode + "-" + m_ListCode + "-" + m_NodeCode;
        }

        public virtual ArrayList GetRelateObjectInfo()
        {
            ArrayList al = new ArrayList();
            //al.Add(new string[] { typeof(AssetInfo).Name, "o.AssetType.Id='" + m_Id + "'", m_TypeCode+"_"+m_Name });
            return al;
        }
    }
}